/* eslint valid-jsdoc: "off" */
require('env2')('./.env')
const { env } = process

/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = appInfo => {
  /**
   * built-in config
   * @type {Egg.EggAppConfig}
   **/
  const config = exports = {};

  // mysql
  config.mysql = {
    client: {
      host: env.HOST,
      port: env.PORT,
      user: env.USER,
      password: env.PASS,
      database: env.DATABASE
    }
  }

  // CSRF 跨站请求伪造关闭
  config.security = {
    csrf: {
      ignore: () => true
    }
  }

  // cors
  config.cors = {
    origin: '*',
    allowMethods: 'GET,PUT,POST,DELETE'
  }


  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1594947625362_6287';

  // add your middleware config here
  config.middleware = [];

  // add your user config here
  const userConfig = {
    // myAppName: 'egg',
  };

  return {
    ...config,
    ...userConfig
  };
};
